/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: lite perf types
 * Create: 2023-09-27
 */
#ifndef __DFX_LITE_PERF_TYPE_H
#define __DFX_LITE_PERF_TYPE_H
#include <linux/types.h>
#include <linux/sched.h>

#ifndef TASK_COMM_LEN
#define TASK_COMM_LEN                   16
#endif
extern u64 min_schedtime_threshold;
enum trace_record_type_t {
	TYPE_SWITCH,
	TYPE_WAKEUP,
	TYPE_WAKEUP_NEW,
	TYPE_MIGRATE,
	TYPE_SOFTIRQ_ENTRY,
	TYPE_SOFTIRQ_EXIT,
	TYPE_HANDLER_ENTRY,
	TYPE_HANDLER_EXIT,
	TYPE_STAT_RUNTIME,
	NUM_TRACEPOINTS,
	TYPE_E2E_START,
	TYPE_E2E_END,
};

struct switch_record {
	__u64 timestamp;
	int type;
	int cpu;
	int origin_cpu;
	int dest_cpu;
	char prev_comm[TASK_COMM_LEN];
	pid_t prev_pid;
	int prev_prio;
	long prev_state;
	pid_t prev_tgid;
	char next_comm[TASK_COMM_LEN];
	pid_t next_pid;
	int next_prio;
	pid_t next_tgid;
	int irq;
	int irq_ret;
	unsigned int vec_nr;
	char action_name[TASK_COMM_LEN];
	__u64 runtime;
};

struct lite_bandwidth_info {
	int nr_periods;
	int nr_throttled;
	__u64 throttled_time;
};


#define DFX_SCHED_IOCTL_MAGIC  'a'

#define DFX_SCHED_IOCTL_ENABLE	_IOR(DFX_SCHED_IOCTL_MAGIC, 1, int)
#define DFX_SCHED_IOCTL_DISABLE _IOR(DFX_SCHED_IOCTL_MAGIC, 2, int)

enum dfx_sched_flag_status {
	DFX_SCHED_FLAG_DEFAULT = 0,
	DFX_SCHED_FLAG_NORMAL = 1,
};

struct lite_perf_sched_param {
	long e2e_id;
	__u64 timeout;
};

struct sched_delay_info {
	int cpuid;
	pid_t pid;
	pid_t tgid;
	int flag;
	unsigned long delay;
	unsigned long avg_delay;
	unsigned long timestamp;
	unsigned int scount;
	unsigned int nr_switchs;
	char comm[TASK_COMM_LEN];
	struct lite_bandwidth_info b_info;
	long e2e_id;
};
#endif

